package cn.lzm.server;

import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;

/**
 * @author lzm
 * @Date 2024/7/15
 * @description
 */
public class VertxHttpServer implements Server {

    @Override
    public void start(int port) {
        Vertx vertx = Vertx.vertx();
        HttpServer httpServer = vertx.createHttpServer();
        httpServer.requestHandler(new HttpServerHandler());

        httpServer.listen(port, event -> {
            if (event.succeeded()) {
                System.out.printf("服务器已经启动，正在监听%s端口\n", port);
            } else {
                System.out.printf("服务启动失败，失败原因：%s\n", event.cause());
            }
        });

    }
}
